<?php
/**
 * Created by PhpStorm.
 * User: HLG
 * Date: 2019/10/16
 * Time: 14:01
 */
namespace app\api\model;
use app\common\model\UploadFile;
use think\Request;
use think\Db;
class GoodImg extends BaseModel
{
    protected $table = 'yoshop_goods_image';

    public function getImg($goods_id)
    {
        $list = $this
            ->alias('i')
            ->join('upload_file f','i.image_id=f.file_id','left')
            ->where('goods_id',$goods_id)
            ->field('file_url,file_name,storage')
            ->select();
        $uploadFile = new UploadFile();
        foreach($list as $k=>$v){
            $src = $uploadFile->getFilePathAttr('',$v);
            $list[$k]['goods_img'] = $src;
        }
        return $list;
    }
}